<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var sum = 0;  // 起始值为0 
     for (var num=1;num<10;num=num+1) {
      sum = sum + num
      // sum=0+1   1
      // sum=1+2   3
      // sum=3+3   6
      // ...
      // sum = sum + 9
      console.log(sum)
    }
  </script>
</body>
</html>